<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link href="{%$URL%}style/webstyle.css" rel="stylesheet" type="text/css" />
<title>{%$web_name%}</title>
<script type="text/javascript">
function newgdcode(obj,url) {
	obj.src = url+ '&nowtime=' + new Date().getTime();//后面传递一个随机参数，否则在IE7和火狐下，不刷新图片
}
// 表单提交客户端检测
function Isyx(yx){
	var reyx= /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
	return(reyx.test(yx));
	}
function doSubmit(){
	var Rname=document.getElementById("Rlc_name");
	var Rtel=document.getElementById("Rlc_tel");
	var Remail=document.getElementById("Rlc_email");
	var Rtitle=document.getElementById("Rlc_title");
	var Rcontent=document.getElementById("Rlc_content");
	var Ryzm=document.getElementById("Ryzm");
    if (document.myform.lc_name.value==""){
        Rname.innerHTML="亲，请写姓名！";
		Rname.style.color="red";
        document.myform.lc_name.focus();
        return false;
    }
    
    if (document.myform.lc_name.value.length>5||document.myform.lc_name.value.length<1 ){
        Rname.innerHTML="亲,您输入的姓名必须在1~5个字之间！";
		Rname.style.color="red";
        document.myform.lc_name.focus();
        return false;
    }
    var reg =/(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/; 
    if (document.myform.lc_tel.value==""){
        Rtel.innerHTML="亲，请写电话！";
		Rtel.style.color="red";
        document.myform.lc_tel.focus();
        return false;
    }
    if(!reg.test(document.myform.lc_tel.value)){ 
        Rtel.innerHTML="亲，请输入正确的电话！";
		Rtel.style.color="red";
        document.myform.lc_tel.focus();
        return false; 
     }
    
    if (document.myform.lc_email.value==""){
        Remail.innerHTML="亲，请写邮箱！";
		Remail.style.color="red";
        document.myform.lc_email.focus();
        return false;
    }
    if (!Isyx(document.myform.lc_email.value)){
		 Remail.innerHTML="亲，请输入正确的邮箱地址！";
		 Remail.style.color="red";
		 document.myform.lc_email.value="";
		 document.myform.lc_email.focus();
		 return false;
     }
     
    if (document.myform.lc_title.value==""){
        Rtitle.innerHTML="亲，请填写您留言的标题！";
		Rtitle.style.color="red";
        document.myform.lc_title.focus();
        return false;
    }
    if (document.myform.lc_content.value==""){
        Rcontent.innerHTML="亲，请填写您的留言内容！";
		Rcontent.style.color="red";
        document.myform.lc_content.focus();
        return false;
    }
    if (document.myform.yzm.value==""){
        Ryzm.innerHTML="亲，请填写验证码！";
		Ryzm.style.color="red";
        document.myform.yzm.focus();
        return false;
    }
}
//数据填写验证
function check_name(obj){
	//验证 姓名
	var name=obj.value;
	var Rname=document.getElementById("Rlc_name");
	if(name){
		if(name.length>5 || name.length<1){
			Rname.innerHTML="亲,您输入的姓名必须在1~5个字之间！";
			Rname.style.color="red";
			}else{
				Rname.innerHTML="正确";
				Rname.style.color="green";
				}
		}else{
			Rname.innerHTML="亲，请写姓名！";
			Rname.style.color="red";
			}
	}
function check_tel(obj){
	//验证 电话
	var tel=obj.value;
	var Rtel=document.getElementById("Rlc_tel");
	if(tel){
		var reg =/(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/;
		if(!reg.test(tel)){
			Rtel.innerHTML="亲，请输入正确的电话！";
			Rtel.style.color="red";
			}else{
				Rtel.innerHTML="正确";
				Rtel.style.color="green";
				}
		}else{
			Rtel.innerHTML="亲，请写电话！";
			Rtel.style.color="red";
			}
	}
function check_email(obj){
	//验证 邮箱
	var email=obj.value;
	var Remail=document.getElementById("Rlc_email");
	if(email){
		if(!Isyx(email)){
			Remail.innerHTML="亲，请输入正确的邮箱地址！";
	 		Remail.style.color="red";
			}else{
				Remail.innerHTML="正确";
				Remail.style.color="green";
				}
		}else{
			Remail.innerHTML="亲，请写邮箱！";
			Remail.style.color="red";
			}
	}
function check_title(obj){
	//验证 标题
	var title=obj.value;
	var Rtitle=document.getElementById("Rlc_title");
	if(title){
		Rtitle.innerHTML="正确";
		Rtitle.style.color="green";
		}else{
			Rtitle.innerHTML="亲，请填写您留言的标题！";
			Rtitle.style.color="red";
			}
	}
function check_content(obj){
	//验证 内容
	var content=obj.value;
	var Rcontent=document.getElementById("Rlc_content");
	if(content){
		Rcontent.innerHTML="正确";
		Rcontent.style.color="green";
		}else{
			Rcontent.innerHTML="亲，请填写您的留言内容！";
			Rcontent.style.color="red";
			}
	}
</script>
</head>
<body>
  <!--头部 开始-->
{%include file='head.htm'%}
<!--头部 结束--> 
<!--内容 开始-->
<div class="nr" style="padding:0 0 40px 0;">
  <div class="main_title"> <span class="main_t">留言板</span><br>
    <!-- Wonderful Case  --></div>
  <div style="padding:40px 0 0 0;">
    <div class="main_l">
      <div class="main_l_title"><span style="font-size:22px;">栏目分类</span><br>
        <!-- Wonderful case --></div>
      <div class="main_l_list">
        <ul>
          <li><a href="index.php?p=gbook&lanmu={%$smarty.get.lanmu%}">留言板</a></li>
          <li><a href="index.php?p=gbook_list&lanmu={%$smarty.get.lanmu%}">留言列表</a></li>
        </ul>
      </div>
    </div>
    <div class="main_r">
      <div class="main_ly">
        <ul>
          <form action="index.php?a=gbook_save" method="post" name="myform" onSubmit="return doSubmit()">
          <li>
            <div class="main_ly_t1">姓   名：</div>
            <input type="text" name="lc_name" id="lc_name" class="main_bd" required onBlur="check_name(this)">
            <div class="main_ly_t2"><span id="Rlc_name">必填，且在1~5个字之间</span></div>
            <div class="cl"></div>
          </li>
          <li>
            <div class="main_ly_t1">电   话：</div>
            <input type="text" name="lc_tel" id="lc_tel" class="main_bd" required onBlur="check_tel(this)">
            <div class="main_ly_t2"><span id="Rlc_tel">请按照正确格式填写，例150********</span></div>
            <div class="cl"></div>
          </li>
          <li>
            <div class="main_ly_t1">邮   箱：</div>
            <input type="text" name="lc_email" id="lc_email" class="main_bd" required onBlur="check_email(this)">
            <div class="main_ly_t2"><span id="Rlc_email">请按照正确邮箱格式填写，例：******@qq.com</span></div>
            <div class="cl"></div>
          </li>
          <li>
            <div class="main_ly_t1">标   题：</div>
            <input type="text" name="lc_title" id="lc_title" class="main_bd" required onBlur="check_title(this)">
            <div class="main_ly_t2"><span id="Rlc_title">请填写您留言的标题</span></div>
            <div class="cl"></div>
          </li>
          <li>
            <div class="main_ly_t1" style="padding:40px 0 0 0;">内   容：</div>
            <textarea name="lc_content" id="lc_content" class="main_bd1" required onBlur="check_content(this)"></textarea><span id="Rlc_content"></span>
            <div class="cl"></div>
          </li>
          <li>
            <div class="main_ly_t1">验证码：</div>
            <input type="text" name="yzm" id="yzm" class="main_bd2">
            <a style="float:left;margin:0 0 0 10px;"><img src="index.php?a=imagecode" alt="看不清楚，换一张" align="absmiddle" style="cursor:pointer;margin-bottom:3px;" onClick="newgdcode(this,this.src)"></a>
            <div class="cl"></div>
          </li>
          <li>
            <div class="main_but">
              <input type="image" name="tijiao" id="tijiao" src="{%$URL%}images/t2.jpg" class="fl">
              <input type="reset" id="chongzhi" style="margin-left:30px; height:35px; width:100px; border:0px; font-size:16px;" value="重    置">
              <div class="cl"></div>
            </div>
          </li>
          </form>
        </ul>
      </div>
    </div>
    <div class="cl"></div>
  </div>
</div>
    <!-- right -->
    <div class="clear"></div>
  </div>
  {%include file="bot.htm"%}</div>
<!-- body --> 
<br>
<br>
</body>
</html>
